#include "script/glue/LuaGlue.h"

#include <OgreMath.h>

namespace LuaGlue
{

	int Radian::create(lua_State *L)
	{
		double f = luaL_checknumber(L, 1);
		Ogre::Radian *r = new Ogre::Radian(f);
		lua_boxpointer(L,r);

		luaL_getmetatable(L, className);
		lua_setmetatable(L, -2);
		return 1;
	}

	int Radian::tostring (lua_State *L)
	{
		char buff[255];
		Ogre::Radian* r = unwrap<Ogre::Radian>(L, 1);
		double v = r->valueRadians();
		sprintf(buff, "%f", v);
		lua_pushfstring(L, "Radian (%s)", buff);

		return 1;
	}

	int Radian::valueDegrees(lua_State *L)
	{
		Ogre::Radian *r = unwrap<Ogre::Radian>(L, 1);
		lua_pushnumber(L, r->valueDegrees());
		return 1;
	}

}

DECLARE(Radian)
META(Radian)
{"__tostring", LuaGlue::Degree::tostring},
METHODS(Radian)
method(LuaGlue::Radian, valueDegrees),
END

